package com.zzq.demo.hibernate.entity;

import lombok.ToString;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author : zhaoziqian
 * @description : 用于测试Hibernate的表映射
 * @date : 2019/9/11 15:30
 */
@Entity
@Table(
        // 表名
        name = "tt_model",
        // 唯一性约束，可以定义单个列也可以定义多个列,做联合主键
        uniqueConstraints = {@UniqueConstraint(name = "uni_1", columnNames = {"id", "uuid"})},
        // 定义索引
        indexes = {@Index(name = "idx_1", columnList = "num"),}
)
@ToString
public class Model {

    @Id
    @Column(name = "id", nullable = false, columnDefinition = "bigint(20) comment '自增主键'")
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;

    @Column(name = "uuid",nullable = false,columnDefinition = "varchar(36) comment 'uuid'")
    private String uuid;

    @Column(name = "num",nullable = false,columnDefinition = "bigint(20) comment '编号'")
    private Long num;

    @Column(name = "status",nullable = false,columnDefinition = "int(3) default 1 comment '状态 0-不可用 1-可用'")
    private Integer status;

    @Column(name = "is_delete",nullable = false, columnDefinition = "bit(1) default b'0' comment '是否删除'")
    private Boolean isDelete;

    @Column(name = "price",nullable = false, columnDefinition = "decimal(11,2) default 0 comment '金额'")
    private BigDecimal price;

    @Column(name = "remark",nullable = true,columnDefinition = "longtext comment'备注'")
    private String remark;

    @Column(name = "name",nullable = false,columnDefinition = "varchar(100) comment'名称'")
    private String name;

    @Column(name = "time",nullable = true,columnDefinition = "datetime comment '时间'")
    private Date time;

//    @Column(name = "ctime",nullable = true, columnDefinition = "timestamp")
//    private Date ctime;
//
//    public Date getCtime() {
//        return ctime;
//    }
//
//    public void setCtime(Date ctime) {
//        this.ctime = ctime;
//    }
//
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Long getNum() {
        return num;
    }

    public void setNum(Long num) {
        this.num = num;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Boolean getDelete() {
        return isDelete;
    }

    public void setDelete(Boolean delete) {
        isDelete = delete;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }
}
